//
//  ZXCheckAppVersionHttpError.m
//  MobileCaiLocal
//
//  Created by simon on 2021/5/26.
//  Copyright © 2021 com.Chs. All rights reserved.
//

#import "ZXCheckAppVersionHttpError.h"

static NSString *const TEXT_ERROR_NETWORK = @"网络异常，请检查你的网络设置";
static NSString *const kCheckVersionAPIErrorDomain = @"com.CheckVersionAPI.domain";

@implementation ZXCheckAppVersionHttpError


/// 自定义NSError
/// @param msg 提示信息
/// @param code 整型errorCode
/// @param userInfoErrorCode 字符串形式的errorCode
+ (NSError *)customErrorWithMsg:(nullable NSString *)msg errorCode:(NSInteger)code userInfoErrorCode:(nullable NSString *)userInfoErrorCode
{
    if (!msg) {
        msg =@"";
    }
    NSDictionary *dic = [NSDictionary dictionaryWithObject:msg forKey:NSLocalizedDescriptionKey];
    NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:dic];
    if (userInfoErrorCode)
    {
        [userInfo setObject:userInfoErrorCode forKey:@"code"];
    }
    NSError * error = [NSError errorWithDomain:kCheckVersionAPIErrorDomain code:code userInfo:userInfo];
    return error;
}


+ (NSString *)errorMsgWithHttpConnectErrorCode:(NSInteger)code{
    
    NSString *description = [NSString stringWithFormat:@"%@(%@)",TEXT_ERROR_NETWORK,@(code)];
    return description;
}
@end
